/***************************************
 2010-4-21
 ****************************************/
package com.happy.action.index;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.core.orm.hibernate.Page;
import com.happy.entity.Ariticle;
import com.happy.services.AriticleServices;
import com.opensymphony.xwork2.ActionSupport;

public class IndexAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1856312234121899958L;

	protected final Logger logger = LoggerFactory.getLogger(getClass());
	private Page<Ariticle> ariticlePage = new Page<Ariticle>(10, true);
	private int pageSize =3;
	private int pageNo = 1;
	private String search="";
	@Autowired
	AriticleServices services;

	/** 默认无参构造函数 **/
	public IndexAction() {
	}

	public String execute() {

		ariticlePage.setPageNo(pageNo);
		ariticlePage.setPageSize(pageSize);
		ariticlePage = services.findByPage(ariticlePage);
		return SUCCESS;
	}

	public String search() {
		ariticlePage.setPageNo(pageNo);
		ariticlePage.setPageSize(pageSize);
		ariticlePage = services.search(search, ariticlePage);
		return "search";
	}

	public String login() {
		logger.info("有用户登录.......");
		return "login";
	}

	public Page<Ariticle> getAriticlePage() {
		return ariticlePage;
	}

	public void setAriticlePage(Page<Ariticle> ariticlePage) {
		this.ariticlePage = ariticlePage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public AriticleServices getServices() {
		return services;
	}

	public void setServices(AriticleServices services) {
		this.services = services;
	}

	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}
	

}
